<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="org.scc.model.User" %>  
<%
	User user = (User)session.getAttribute("user");
%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/base.css" />
<link rel="stylesheet" type="text/css" href="../css/top.css" />
<script type="text/javascript" src="../easyui/jquery-1.8.0.min.js"></script>
<title>首页</title>
<script type="text/javascript">
	$(function() {
		initFrameHeight();
		initUserNav();
	});

	function initNav() {
		$(".mainmenu").hover(function() {
			$(this).addClass("mainmenuon");
			$(this).find(".subnav").slideDown('fast');
		}, function() {
			$(this).find(".subnav").slideUp('fast');
			$(this).removeClass("mainmenuon");
		});
	}
	
	function initUserNav(){
		$.ajax({
			   type: "POST",
			   url: "../role/getUserRoleRes.do",
			   dataType: "json",
			   success: function(ress){
				   var content = "";
				   var cldRess;
				   for(var i = 0; i < ress.length; i++){
					   content += "<li class='mainmenu'>" + "<a href='#' url='"+ress[i].url+"'>"+ress[i].text+"</a>";
					   cldRess = ress[i].children;
					   if(cldRess.length > 0){
						   content += "<ul class='subnav'>";
						   for(var j = 0; j < cldRess.length; j++){
							   content += "<li class='submenu'><a href='#' url='"+cldRess[j].url+"'>"+cldRess[j].text+"</a></li>";
						   }
						   content += "</ul>";
					   }
				   }
				   $(".mainnav").append(content);
				   initNav();
				   initLink();
			   }
		});
	}
	
	function initLink(){
		$(".mainnav a").mousedown(function(){
			$("#mainFm").attr("src", $(this).attr("url") );
			return false;
		});
	}
	
	function setFrameSrc(src){
		$("#mainFm").attr("src", src );
	}
	
	function initFrameHeight(){
		var height = $(document).height();
		$("#mainFm").height(height - 60);
	}
</script>
</head>
<body>
	<div id="header">
		<div id="nav">
			<ul class="mainnav">
			</ul>
			<div id="logout">
				<table>
					<tr>
						<td><%=user.getName() %>，您好！</td>
						<td width="25px"><a href="../user/logout.do" title="退出系统"><img src="../image/logout.png" alt="退出" /></a></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div id="main">
		<iframe style="width: 100%;" frameborder="0" id="mainFm"></iframe>
	</div>

	<!-- <div id="footer"></div> -->
</body>
</html>
